package com.big.order.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.big.common.result.Result;
import com.big.model.model.order.MerchandiseOrder;
import com.big.model.vo.order.OrderInfoQueryVo;
import com.big.order.service.OrderService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/order")
public class OrderAdminController {


    @Autowired
    private OrderService orderService;

    //订单列表（条件查询带分页）
    @GetMapping("/infos/{page}/{limit}")
    @ApiOperation(value = "查询订单列表")
    public Result list(@PathVariable Long page,
                       @PathVariable Long limit,
                       OrderInfoQueryVo orderInfoQueryVo) {
        Page<MerchandiseOrder> pageParam = new Page<>(page,limit);
        IPage<MerchandiseOrder> pageModel = orderService.selectPage(pageParam,orderInfoQueryVo);
        return Result.ok(pageModel);
    }



    @GetMapping("/adminOrderInfo/{did}")
    @ApiOperation(value = "查询订单详情")
    public Result adminOrderInfo(@PathVariable("did") String did) {
        MerchandiseOrder merchandiseOrder = orderService.adminOrderInfo(did);
        return Result.ok(merchandiseOrder);
    }

    /**
     * 审核确认,改变状态发货
     */
    /**
     *  订单状态更改
     */
    @ApiModelProperty(value = "订单状态更改")
    @GetMapping("/upShipments/{phone}/{oId}")
    public boolean  upShipments(@PathVariable String phone, @PathVariable String oId) {
        boolean b = orderService.upShipments(phone, oId);
        return b;
    }

}
